package com.chenl.provider.util;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;

public class DateUtils {
    public static Long checkDateUtil(Object startTime,Object endTime){
        LocalDate start =null;
        LocalDate end =null;
        if (startTime instanceof LocalDate){
            start= (LocalDate) startTime;
        }else if (startTime instanceof String){
            start = LocalDate.parse((String) startTime, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
        }
        if (endTime instanceof LocalDate){
            end= (LocalDate) endTime;
        }else if (endTime instanceof String){
            end = LocalDate.parse((String) endTime, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
        }
        long days = start.until(end, ChronoUnit.DAYS);
        return days;
    }
}
